﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KPIS.GERP.GHRMS.MODEL
{
    public class AbsenceRuleInfo : RecordInfo
    {
        private int rule_seq;
        private EmployeeTypeInfo emp_type_seq;
        private AbsenceTypeInfo absence_type_seq;
        private decimal quota_day;
        private decimal quota_salary;
        private decimal quota_half_salary;
        private decimal quota_count;
        private decimal quota_day_count;
        private bool incl_nonWorkingDay;
        private decimal? send_before;

        public AbsenceRuleInfo()
        {

        }
        public AbsenceRuleInfo(int Sequence)
        {
            this.Sequence = Sequence;
        }

        public AbsenceRuleInfo(int Sequence, EmployeeTypeInfo EmployeeType, AbsenceTypeInfo AbsenceType
            , decimal QuotaDay, decimal QuotaDaySalary, decimal QuotaDayHalfSalary, decimal QuotaCount, decimal DayPerCount
            , string Remarks, string RecordStatus, Nullable<int> CreatedBy, Nullable<int> UpdatedBy, bool inclNonWorkingDay)
        {
            this.Sequence = Sequence;
            this.EmployeeType = EmployeeType;
            this.AbsenceType = AbsenceType;
            this.QuotaDay = QuotaDay;
            this.QuotaDaySalary = QuotaDaySalary;
            this.QuotaDayHalfSalary = QuotaDayHalfSalary;
            this.QuotaCount = QuotaCount;
            this.DayPerCount = DayPerCount;
            this.Remarks = Remarks;
            this.RecordStatus = RecordStatus;
            this.CreatedBy = CreatedBy;
            this.UpdatedBy = UpdatedBy;
            this.IncludeNonWorkingDay = inclNonWorkingDay;
        }

        public int Sequence
        {
            get
            {
                return rule_seq;
            }
            set
            {
                rule_seq = value;
            }
        }
        
        public int? EmployeeTypeSeq { get; set; } 
        public EmployeeTypeInfo EmployeeType
        {
            get
            {
                return emp_type_seq;
            }
            set
            {
                emp_type_seq = value;
            }
        }

        public AbsenceTypeInfo AbsenceType
        {
            get
            {
                return absence_type_seq;
            }
            set
            {
                absence_type_seq = value;
            }
        }

        public enum UseSendBeforeEnum
        {
            NotUse, // ไมใช้การลาล่วงหน้า
            UseSendBefore, // ต้องลาล่วงหน้าอย่างน้อย
            UseSendAfter // สามารถลาย้อนหลังได้ไม่เกิน


        }

        public void SetSendBefore(UseSendBeforeEnum useSendBeforeEnum, decimal? sendBeforePlusValue)
        {
            if(useSendBeforeEnum == UseSendBeforeEnum.NotUse)
            {
                send_before = null;
            } else if(useSendBeforeEnum == UseSendBeforeEnum.UseSendBefore)
            {
                send_before = sendBeforePlusValue;
            } else
            {
                send_before = sendBeforePlusValue * -1;
            }
        }

        public UseSendBeforeEnum UseSendBefore
        {
            get
            {
                if(send_before == 0 || send_before == null)
                {
                    return UseSendBeforeEnum.NotUse;
                } else if(send_before > 0)
                {
                    return UseSendBeforeEnum.UseSendBefore;
                }else
                {
                    return UseSendBeforeEnum.UseSendAfter;
                }
            }
        }

        public decimal? SendBefore
        {
            get { return send_before; }
            set { send_before = value; }
        }

        public int? AbsenceTypeSeq
        {
            get { return absence_type_seq != null ? absence_type_seq.Sequence : (int?) null; }

        }

        public decimal QuotaDay
        {
            get
            {
                return quota_day;
            }
            set
            {
                quota_day = value;
            }
        }

        public decimal QuotaDaySalary
        {
            get
            {
                return quota_salary;
            }
            set
            {
                quota_salary = value;
            }
        }
        public decimal QuotaDayHalfSalary
        {
            get
            {
                return quota_half_salary;
            }
            set
            {
                quota_half_salary = value;
            }
        }

        public decimal QuotaCount
        {
            get
            {
                return quota_count;
            }
            set
            {
                quota_count = value;
            }
        }

        public decimal DayPerCount
        {
            get
            {
                return quota_day_count;
            }
            set
            {
                quota_day_count = value;
            }
        }        
        public bool IncludeNonWorkingDay
        {
            get
            {
                return incl_nonWorkingDay;
            }
            set
            {
                incl_nonWorkingDay = value;
            }
        }

        public int? GenderSeq { get; set; }
        
    }
}
